/**
 * Created by d on 2015/12/28.
 */
define(function (require, exports, module) {
    'use strict'
    
    var rk = require('rk');

    require('crm/js/apps/crm/crm');
    var constant = require('crm/js/apps/common/constant')


    $.widget('rk.oa_list', $.rk.crm, {    
        setTitle : function(){
        	var me = this,
                elem = me.element,
                opt = me.options;

            var fromBelongId = rk.getUrlParam('fromBelongId');
            var fromDataId = rk.getUrlParam('fromDataId');

            $.post('/json/crm_oa/fromobject.action', 
                {fromBelongId: fromBelongId,
                    fromDataId : fromDataId
                }, 
                function(json, textStatus, xhr) {
                    var json = $.parseJSON(json);
                    var rkTitle = (SESSION.keywords[json.data.fromObject.actionName]  || json.data.fromObject.belongLabel);
                    var belongIdParam = json.data.fromObject.belongId>999?"&belongId="+json.data.fromObject.belongId:"";
                    var detailLink=["/",json.data.fromObject.actionName,"_detail.action?id="
                                    ,json.data.fromObject.id,belongIdParam].join("");
                    rk.setTitle([rkTitle,{title:json.data.fromObject.name,href:detailLink}]);
                }
            );

        }
    });

});